package offer;

import java.util.Stack;

public class offer_0009 {
    class CQueue {
        Stack<Integer> stack1;
        Stack<Integer> stack2;
        int current1;
        public CQueue() {
            stack1=new Stack<>();
            stack2=new Stack<>();
            current1=0;
        }

        public void appendTail(int value) {
            stack1.push(value);
            current1++;
        }

        public int deleteHead() {
            if(current1==0) return -1;
            for(int i=0;i<current1;++i){
                int tem=stack1.pop();
                stack2.push(tem);
            }
            int re=stack2.pop();
            current1--;
            for(int i=0;i<current1;++i){
                int tem=stack2.pop();
                stack1.push(tem);
            }
            return re;
        }
    }
}
